package com.qidianit.mes.pro.controller;

import com.github.pagehelper.PageInfo;
import com.qidianit.mes.pojo.ProcessStep;
import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pro.service.ProcessStepService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ Description:
 * @ Author:WuJingLei
 * @ Date: 2025/9/17 -17:04
 */
@RestController
@RequestMapping("/processStep")
public class ProcessStepController {
    @Autowired
    private ProcessStepService stepService;

    @GetMapping("/page")
    public Result<PageInfo<ProcessStep>> page(Long processId,
                                              @RequestParam(defaultValue = "1") int pageNum,
                                              @RequestParam(defaultValue = "10") int size){
        return stepService.queryProcessSteps(processId,pageNum,size);
    }

    @GetMapping("/get/{id}")
    public Result<ProcessStep> get(@PathVariable Long id){
        return stepService.getProcessStep(id);
    }

    @PostMapping("/add")
    public Result<ProcessStep> add(@RequestBody ProcessStep processStep ){
        return  stepService.saveProcessStep(processStep);
    }

    @PutMapping("/update")
    public Result update(@RequestBody ProcessStep processStep){
        return stepService.updateStep(processStep);
    }

    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable Long id){
        return stepService.deleteStep(id);
    }
}
